import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * Write a description of class PezGlobo here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class PezGlobo  extends Pez
{

    /**
     * Act - do whatever the PezGlobo wants to do. This method is called whenever
     * the 'Act' or 'Run' button gets pressed in the environment.
     */
    GreenfootImage Globo = new GreenfootImage("pezglobo4.gif");
    GreenfootImage Globo2 = new GreenfootImage("pezglobo4.gif");
    
    int i = 1;
    boolean band = true;
    boolean band2 = true;
    int cont = 0;
    
    /**
     * Escala las dos imagenes, la del pez globo inflandose y desinflandose
     */
     public PezGlobo(int c)
    {
        this.setImage(Globo);
        Globo.scale(55,35);
        Globo2.scale(20,10);
        Globo.mirrorHorizontally();
        Globo2.mirrorHorizontally();
        cont=c;
    }
    /**
     * Este metodo realiza la accion de avanzar, ademas de que cada determinado tiempo
     * el pez se incha y deshincha
     */
    public void act() 
    {
       if(band)
        {
           setLocation(getX()+i, getY());
           // Add your action code here.
        }
        else
           setLocation(getX()-i, getY());
           
        if(getX()>=550)
        {
            Globo.mirrorHorizontally();
            Globo2.mirrorHorizontally();
            band = false;
        } 
        
        if(getX()<=1)
        {
            Globo.mirrorHorizontally();
            Globo2.mirrorHorizontally();
            band = true;
            
        }
       
        
        if(cont==150&&band2==true)
        {
            this.setImage(Globo);
            cont=0;
            band2=false;
        }
        
        if(cont==150&&band2==false)
        {
            
            this.setImage(Globo2);
            cont=0;
            band2=true;
        }
        cont++;   
    }    
}
